package com.gitee.service;

import cn.hutool.crypto.SecureUtil;
import com.gitee.domain.system.dto.LoginBody;
import com.gitee.domain.system.po.SysUser;
import com.gitee.mapper.system.SysUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName：LoginService
 * @Author: bin
 * @Date: 2024/11/2 16:00
 * @Description: 登录校验
 */
@Service
@Slf4j
public class LoginService {
    @Autowired
    private SysUserMapper userMapper;

    public void checkLogin(LoginBody loginBody) {
        String username = loginBody.getUsername();
        String password = SecureUtil.md5(loginBody.getPassword());
        SysUser user = userMapper.queryByUsername(username);
        if (user == null) {
            //TODO 返回异常：用户名或者密码不对。
        }
        if (!user.getPassword().equals(password)) {
            // TODO 返回异常：用户名密码错误
        }
    }
}
